from user import *
from payment import *
import sys

def create():
    u1=User("Chi")
    u2=User("Bill")
    u3=User("Shulei")
    u4=User("you know who")

    for usr in User.getAllUsers():
        usr.activate()
    u4.deactivate()

    print "Users:"
    for usr in User.getAllUsers():
        print str(usr)
    print "\n--------\n"

    u1.changeName("Tony")
    print "adding aliases..."
    u1.addAlias("Chi")
    u1.addAlias("CZ")
    u1.removeAlias("CZ")
    print u1.getAliases()
    u1.addAlias("CZ")

    for usr in User.getAllUsers():
        print str(usr)
    print "\n--------\n"

    p1=Profile("empty profile")
    p2=Profile("NoPayee?", u1)
    p3=Profile("T-mobile", u1, u2)
    print Profile.getProfile("empty profile")
    print Profile.getProfile("NoPayee?")
    print Profile.getProfile("T-mobile")
    print Profile.getProfile("Tmobile") # this should return None
    print "\n--------\n"
    print p3.debug()
    print "adding u4..."
    p3.addPayee(u4)
    print p3.debug()
    print "removing u4, adding u3..."
    p3.addPayee(u3)
    p3.removePayee(u4)
    print p3.debug()
    print "bal: u1 = {0}, u2 = {1}, u3 = {2}, u4 = {3}".format(
        p3.getBalance(u1.getAliasList()[1]), p3.getBalance(u2.getName()),
        p3.getBalance(u3.getID()), p3.getBalance(u4.getID())
        )
    return


def dump():
    print "\n--------\n--------\n"
    print "user:"
    su = User._dump_()
    print repr(su)
    print "profile:"
    sp = Profile._dump_()
    print repr(sp)
    return


def final():
    print "\n--------\n"
    print "*** Final result ***"
    print "Users:"
    for usr in User.getAllUsers():
        print repr(usr)
    print "\nProfiles:"
    for profile in Profile._obj_dict_.itervalues():
        print repr(profile)
    return


# entry point
if __name__ == '__main__':
    create()
    final()

    dump()
